﻿//**************************************************************
//
// MoneyBaby Project - Open source payment processors for .NET
//
// Copyright 2007-2008 Marcus McConnell and BV Software
// www.CodePlex.com/MoneyBaby
//**************************************************************

using System;
using System.Collections.Generic;
using System.Text;

namespace BVSoftware.MoneyBaby
{
    public class CreditCardProcessor
    {
        private CreditCardProcessor()
        {           
        }

        public static ICreditCardGateway GetGateway(CreditCardProcessorType processorType)
        {
            switch (processorType)
            {
                case CreditCardProcessorType.AuthorizeNet:
                    return (ICreditCardGateway)new Gateways.AuthorizeNet();
                case CreditCardProcessorType.LinkPointConnect:
                    return (ICreditCardGateway)new Gateways.LinkPointConnect();
                case CreditCardProcessorType.WorldPayJuniorSelect:
                    return (ICreditCardGateway)new Gateways.WorldPayJuniorSelectGatewaySettings();
                default:
                    return null;
            }
        }

        public static Gateways.AuthorizeNet GetAuthorizeNetGateway()
        {
            return new Gateways.AuthorizeNet();
        }

        public static Gateways.LinkPointConnect GetLinkPointConnectGateway()
        {
            return new Gateways.LinkPointConnect();
        }

        public static Gateways.WorldPayJuniorSelect GetWorldPayJuniorSelectGateway()
        {
            return new Gateways.WorldPayJuniorSelect();
        }
        
        public static ICreditCardGateway<U> GetGateway<T,U>()
            where T : ICreditCardGateway<U>
            where U : PaymentGatewaySettings, new()
        {
            return (ICreditCardGateway<U>)Activator.CreateInstance(typeof(T), true);
        }        
    }
}
